import axios from "axios";

const instance = axios.create({
  //设置默认地址
  baseURL: "http://kumanxuan1.f3322.net:8001",
  // 请求超时时间
  timeout: 5000,
});

//请求拦截
instance.interceptors.request.use((config) => {
  //config   存储请求的配置信息
  // console.log('请求拦截');
  let token = localStorage.getItem("token");
  if (token) {
    config.headers.common = {
      "X-Nideshop-Token": token,
    };
  }
  return config;
});

//响应拦截
instance.interceptors.response.use((res) => {
  // console.log('响应拦截');
  return res.data;
});

export default instance;
